home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 25 / AMIGAplus Sonderheft 25 (2000)(Falke)(DE)(Track 1 of 4)[!].iso / PublicDomain / Anwendungen / FragCure / FragCure.s < prev   
Text File  |  1980-01-09  |  3KB  |  136 lines

  1. * FragCure by r@((e (6/10/97)
  2.  
  3. * Proggy that tries to minimise memory fragmentation using the trick
  4. * discovered by the developer of "LowFrag" and a little unstable
  5. * imitated by the man behind "FragLess" (which crashed badly on my 060
  6. * at the uni)
  7.  
  8. * Written on my fascinating A500/512KChip/512KFast/Kick 40.063/1x1MBFDD
  9. * using the ASM-One-clone Trash'M-One at home ,)
  10.  
  11. * Thanks to Lee Kindness for the SFPatch-archive on Aminet, which I used
  12. * to get some knowledge about patching and to the authors of "LowFrag"
  13. * (for the invention) and "FragLess" (for the motivation) of course.
  14.  
  15. _LVOOpenLibrary        =    -552
  16. _LVOCloseLibrary    =    -414
  17. _LVOAllocMem        =    -198
  18. _LVOSetFunction        =    -420
  19. _LVOForbid        =    -132
  20. _LVOPermit        =    -138
  21. _LVOCacheClearU        =    -636
  22.  
  23. MEMF_PUBLIC        =    1
  24. MEMF_REVERSE        =     $40000
  25.  
  26. _LVOReadArgs        =    -798
  27. _LVOFreeArgs        =    -858
  28.  
  29.  
  30. x
  31.     move.l    4.w,a6
  32.     lea    dosname(pc),a1
  33.     moveq    #0,d0
  34.     jsr    _LVOOpenLibrary(a6)    ; open dos library
  35.     lea    dosbase(pc),a0
  36.     move.l    d0,(a0)
  37.     beq    failopendos
  38.  
  39.     move.l    d0,a6
  40.     lea    template(pc),a0
  41.     move.l    a0,d1
  42.     lea    array(pc),a1
  43.     move.l    a1,d2
  44.     moveq    #0,d3
  45.     jsr    _LVOReadArgs(a6)    ; read optional "BYTES"-argument
  46.     lea    rdargs(pc),a0
  47.     move.l    d0,(a0)
  48.     beq.s    failreadargs
  49.  
  50.     move.l    array(pc),a0
  51.     lea    bytes(pc),a1
  52.     move.l    #32768,(a1)        ; default no of bytes for the
  53.                     ; "lower memory region"
  54.     tst.l    (a0)
  55.     beq.s    pickdefault
  56.     move.l    (a0),(a1)        ; copy no of bytes into allocpatch
  57.  
  58. pickdefault:
  59.     move.l    4.w,a6
  60.     moveq    #allocpatchend-allocpatchbeg,d0
  61.     moveq    #MEMF_PUBLIC,d1
  62.     jsr    _LVOAllocMem(a6)    ; allocate some memory for the patch
  63.     lea    patchaddr(pc),a0
  64.     move.l    d0,(a0)
  65.     beq.s    failallocpatch
  66.  
  67.     lea    allocpatchbeg(pc),a0
  68.     move.l    d0,a1
  69.     moveq    #allocpatchend-allocpatchbeg-1,d0
  70. .copy:
  71.     move.b    (a0)+,(a1)+        ; copy patch into its rightful place
  72.     dbf    d0,.copy
  73.  
  74.     move.l    4.w,a6
  75.     jsr    _LVOForbid(a6)        ; dunno if this has to be, copied
  76.                     ; from SFPatch by Lee Kindness
  77.  
  78.     move.l    a6,a1
  79.     move.w    #_LVOAllocMem,a0
  80.     move.l    patchaddr(pc),d0
  81.     jsr    _LVOSetFunction(a6)
  82.     move.l    patchaddr(pc),a0    ; put old address into our routine
  83.                     ; (the routine JMPs back to the
  84.                     ; OS routine after doing the trick)
  85.     move.l    d0,dontpatch-allocpatchbeg+2(a0)
  86.  
  87.     jsr    _LVOCacheClearU(a6)    ; clear cpu cache so the execution
  88.                     ; cache is valid (taken from SFPatch)
  89.  
  90.     jsr    _LVOPermit(a6)        ; taken from SFPatch again
  91.     
  92. failallocpatch:
  93.     move.l    dosbase(pc),a6
  94.     move.l    rdargs(pc),d1
  95.     jsr    _LVOFreeArgs(a6)
  96.  
  97. failreadargs:
  98.     move.l    4.w,a6
  99.     move.l    dosbase(pc),a1
  100.     jsr    _LVOCloseLibrary(a6)
  101.  
  102. failopendos:
  103.     moveq    #0,d0            ; quit out (no error code provided)
  104.     rts
  105.  
  106.  
  107. allocpatchbeg:
  108.     lea    bytes(pc),a0
  109.     cmp.l    (a0),d0
  110.     blt.s    dontpatch
  111.  
  112.     or.l    #MEMF_REVERSE,d1
  113.  
  114. dontpatch:
  115.     jmp    0
  116.  
  117. bytes:
  118.     dc.l    0
  119. allocpatchend:
  120.  
  121.  
  122. dosbase:
  123.     dc.l    0
  124. dosname:
  125.     dc.b    "dos.library",0
  126.     cnop    0,4
  127. template:
  128.     dc.b    "BYTES/N",0
  129.     cnop    0,4
  130. array:
  131.     dc.l    0
  132. rdargs:
  133.     dc.l    0
  134. patchaddr:
  135.     dc.l    0
  136.